/**************************************************************
 * Copyright (c) 2021 anxinsec.com, Inc. All Rights Reserved
 * User: zhangdongsheng<zhangdongsheng@anxinsec.com>
 * Date: 2021/11/21
 * Desc:
 **************************************************************/

package nlog

import (
	"github.com/xfxdev/xtcp"
)

var (
	xTCPLogger *XTCPLogger
)

func GetXTCPLogger() *XTCPLogger {
	if xTCPLogger == nil {
		xTCPLogger = &XTCPLogger{}
	}
	return xTCPLogger
}

type XTCPLogger struct {
}

func (XTCPLogger) Log(l xtcp.LogLevel, v ...interface{}) {
	switch l {
	case xtcp.Debug:
		sugaredLogger(nil).Debug(v)
	case xtcp.Info:
		sugaredLogger(nil).Info(v)
	case xtcp.Warn:
		sugaredLogger(nil).Warn(v)
	case xtcp.Error:
		sugaredLogger(nil).Error(v)
	case xtcp.Fatal:
		sugaredLogger(nil).Fatal(v)
	case xtcp.Panic:
		sugaredLogger(nil).Panic(v)
	default:
	}
}

func (XTCPLogger) Logf(l xtcp.LogLevel, format string, v ...interface{}) {
	switch l {
	case xtcp.Debug:
		sugaredLogger(nil).Debugf(format, v)
	case xtcp.Info:
		sugaredLogger(nil).Infof(format, v)
	case xtcp.Warn:
		sugaredLogger(nil).Warnf(format, v)
	case xtcp.Error:
		sugaredLogger(nil).Errorf(format, v)
	case xtcp.Fatal:
		sugaredLogger(nil).Fatalf(format, v)
	case xtcp.Panic:
		sugaredLogger(nil).Panicf(format, v)
	default:
	}
}
